profiling on demand
authorØyvind Kolås <ok@src.gnome.org>
Mon, 26 Sep 2005 21:58:17 +0000 (21:58 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Mon, 26 Sep 2005 21:58:17 +0000 (21:58 +0000)
ChangeLog
babl/babl-classes.h
babl/babl-format.c
babl/babl-internal.c
babl/babl-internal.h
babl/babl-type.c
babl/babl-util.c
babl/babl-util.h

index 62c5cce851f1df1b7a65ada2e13a40bfd785aa54..4b4fcbe8127d676d33a7da7515404b0c6ba1a675 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2005-09-27  Øyvind Kolås  <pippin@gimp.org>
+
+       * babl/babl-util.h,
+       * babl/babl-util.c: (babl_rel_avg_error): moved buffer comparison
+                                                 function to one place.
+       * babl/babl-classes.h: Added error field to fishes, made path length
+       dynamic.
+       * babl/babl-internal.h: added misc global constants.
+       * babl/babl-internal.c: created caching accessors in classes, to avoid
+       very large bootstrapping time.
+       * babl/babl-conversion.c: (test_create), (babl_conversion_cost),
+       (babl_conversion_error):
+       * babl/babl-format.c: (test_create), (babl_format_loss):
+       * babl/babl-type.c: (babl_type_is_symmetric):
+
+2005-09-27  Øyvind Kolås  <pippin@gimp.org>
+
+       Moved html generator stats code into a seperate source fil in core,
+       babl now creates /tmp/babl-stats.txt when the BABL_STATS enviroment
+       variable is set.
+
+       * babl/Makefile.am:
+       * babl/babl.c:
+       * tests/babl_fish_path_dhtml.c: (main):
+       * babl/babl-fish-stats.c: (table_destination_each).
+
 2005-09-19  Øyvind Kolås  <pippin@gimp.org>
 
        * docs/index-static.html.in: s/DHTML/interactive/
index 007ba97105b5bb231ebdcf710428b4f53baa8036..e7ab444426d5e11af5c7460bfe9532a9044cc607 100644 (file)
@@ -201,8 +201,9 @@ typedef struct
   BablInstance    instance;
   union Babl     *source;
   union Babl     *destination;
-  int   processings;
-  long  pixels;
+  int             processings;
+  long            pixels;
+  double          error;
 } BablFish;
 
 
@@ -232,7 +233,7 @@ typedef struct
   BablFish         fish;
   double           cost;
   double           loss;
-  BablConversion  *conversion[BABL_MAX_PATH_LENGTH];
+  BablConversion  *conversion[BABL_HARD_MAX_PATH_LENGTH];
   int              conversions;
 } BablFishPath;
 
index 4881b049b6ea25cbb3fe89ec51788246a88421d7..0dae68f9d9208318071d3d93c47d4ef782234bbf 100644 (file)
@@ -336,7 +336,7 @@ babl_format_with_model_as_type (Babl *model,
    );
 }
 
-#define pixels  256
+#define test_pixels  256
 
 static double *
 test_create (void)
@@ -346,9 +346,9 @@ test_create (void)
 
   srandom (20050728);
   
-  test = babl_malloc (sizeof (double) * pixels * 4);
+  test = babl_malloc (sizeof (double) * test_pixels * 4);
 
-  for (i = 0; i < pixels * 4; i++)
+  for (i = 0; i < test_pixels * 4; i++)
      test [i] = (double) random () / RAND_MAX;
 
   return test;
@@ -386,27 +386,23 @@ babl_format_loss (Babl *babl)
   fish_from = babl_fish_reference (fmt, ref_fmt);
  
   test        = test_create (); 
-  original    = babl_calloc (pixels, fmt->format.bytes_per_pixel);
-  clipped     = babl_calloc (pixels, ref_fmt->format.bytes_per_pixel);
-  destination = babl_calloc (pixels, fmt->format.bytes_per_pixel);
-  transformed = babl_calloc (pixels,  ref_fmt->format.bytes_per_pixel);
+  original    = babl_calloc (test_pixels, fmt->format.bytes_per_pixel);
+  clipped     = babl_calloc (test_pixels, ref_fmt->format.bytes_per_pixel);
+  destination = babl_calloc (test_pixels, fmt->format.bytes_per_pixel);
+  transformed = babl_calloc (test_pixels,  ref_fmt->format.bytes_per_pixel);
 
-  babl_process (fish_to,   test,        original,    pixels);
-  babl_process (fish_from, original,    clipped,     pixels);
-  babl_process (fish_to,   clipped,     destination, pixels);
-  babl_process (fish_from, destination, transformed, pixels);
+  babl_process (fish_to,   test,        original,    test_pixels);
+  babl_process (fish_from, original,    clipped,     test_pixels);
+  babl_process (fish_to,   clipped,     destination, test_pixels);
+  babl_process (fish_from, destination, transformed, test_pixels);
 
-  {
-    int i;
-
-    for (i=0;i<pixels*4;i++)
-      {
-        loss += fabs (clipped[i] - test[i]);
-      }
-    loss /= pixels;
-
-  }
+  loss = babl_rel_avg_error (clipped, test, test_pixels*4);
   
+  fish_to->fish.processings-=2;
+  fish_from->fish.processings-=2;
+  fish_to->fish.pixels-=test_pixels*2;
+  fish_from->fish.pixels -= test_pixels*2;
+
   babl_free (original);
   babl_free (clipped);
   babl_free (destination);
index 555f672e5f4ae0174984fa7df50efafa000d8a1a..ae7bc265b9955e3151a902a5057f95945bf02abc 100644 (file)
@@ -17,6 +17,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <stdlib.h>
 #include "babl-internal.h"
 
 static const char *class_names[] =
@@ -124,44 +125,3 @@ babl_name (Babl *babl)
   babl_assert (BABL_IS_BABL (babl));
   return babl->instance.name;
 }
-
-static int
-each_conversion (Babl *babl,
-                 void *user_data)
-{
-  babl_conversion_error (&babl->conversion);
-  return 0;
-}
-
-static int
-each_format (Babl *babl,
-             void *user_data)
-{
-  babl_format_loss (babl);
-  return 0;
-}
-
-static int
-gen_type_format_for_model (Babl *type, void *userdata)
-{
-  babl_format_with_model_as_type (userdata, type);
-  return 0;
-}
-
-static int
-gen_formats_for_model (Babl *model, void *userdata)
-{
-  babl_type_each (gen_type_format_for_model, model);
-  return 0;
-}
-
-void
-babl_extension_post_load (void)
-{
-  babl_conversion_each (each_conversion, NULL);
-  babl_format_each     (each_format, NULL);
-    return;
-  babl_model_each (gen_formats_for_model, NULL);
-  babl_format_each     (each_format, NULL);
-}
-
index 6f0973eff68996f7ff829691b520af911bb98b8f..376cb6f8074edfb7c9c99d087c7087921149658c 100644 (file)
@@ -24,8 +24,8 @@
 #error babl-internal.h included after babl.h
 #endif
 
-#define BABL_MAX_COMPONENTS   32
-#define BABL_MAX_PATH_LENGTH  5
+#define BABL_MAX_COMPONENTS       32
+#define BABL_HARD_MAX_PATH_LENGTH  8
 
 #include <stdlib.h>
 #include <stdio.h>
 Babl   * babl_conversion_find           (void           *source,
                                          void           *destination);
 double   babl_conversion_error          (BablConversion *conversion);
+long     babl_conversion_cost           (BablConversion *conversion);
 long     babl_conversion_process        (Babl           *conversion,
                                          void           *source,
                                          void           *destination,
                                          long            n);
 
 Babl   * babl_extension_base            (void);
-void     babl_extension_post_load       (void);
 
 Babl   * babl_extender                  (void);
 void     babl_set_extender              (Babl           *new_extender);
@@ -74,6 +74,7 @@ BablDb * babl_fish_db                   (void);
 Babl   * babl_fish_reference            (Babl           *source,
                                          Babl           *destination);
 Babl   * babl_fish_simple               (BablConversion *conversion);
+void     babl_fish_stats                (FILE           *file);
 Babl   * babl_fish_path                 (Babl           *source,
                                          Babl           *destination);
 
index 81d270ee9031aba10dbfe7d78bf796c2d09f90d6..e04e97dfa065f49705df8fd377c42d1f2282faa7 100644 (file)
@@ -213,6 +213,11 @@ babl_type_is_symmetric (Babl *babl)
   babl_process (fish_to,   clipped,     destination, samples);
   babl_process (fish_from, destination, transformed, samples);
 
+  fish_from->fish.processings-=2;
+  fish_to->fish.processings-=2;
+  fish_from->fish.pixels -= samples*2;
+  fish_to->fish.pixels -= samples*2;
+
   {
     int cnt=0;
     int i;
index 182f5e383b50276f63ca16c97e5f84adee4e21ba..63284fb8251dab5f5a2676f94184a5c725d2f52c 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <math.h>
 #include "babl-memory.h"
 #include "babl-internal.h"
 
@@ -100,3 +101,23 @@ babl_ticks (void)
   gettimeofday (&measure_time, NULL);
   return msecs(measure_time) - msecs(start_time);
 }
+
+double
+babl_rel_avg_error (double *imgA,
+                    double *imgB,
+                    long    samples)
+{
+  double error = 0.0;
+  int i;
+
+  for (i=0; i<samples; i++)
+      error += fabs (imgA[i] - imgB[i]);
+
+  if (error >= 0.000001)
+    error /= samples;
+  else
+    error = 0.0;
+
+  return error;
+}
+
index 9fa11763022a8c6fd366f7348562f142c920c49e..be6c9bcbb93463643ca7e3b96b9450410e8ef0f4 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef _BABL_UTIL_H
 #define _BABL_UTIL_H
 
+#include <math.h>
+
 void   babl_add_ptr_to_list (void       ***list,
                              void         *new);
 
@@ -29,4 +31,9 @@ babl_list_each (void             **list,
                 void              *user_data);
 
 unsigned int    babl_ticks (void);
+
+double
+babl_rel_avg_error (double *imgA,
+                    double *imgB,
+                    long    samples);
 #endif